package com.example.portalfundacao;

import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MenuPrincipalActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu_principal);
        
        ListView menuOptions = (ListView) findViewById(R.id.menuOptions);
        
        String[] options = new String[] {"Agenda de Contatos", "Calendário de Eventos", "Requisições"};
        
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, options);
        
        menuOptions.setAdapter(adapter);
        menuOptions.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View view, int position,
					long id) {
				
				if (id == 1) {
					Intent intent = new Intent(MenuPrincipalActivity.this, CalendarView.class);
					
					intent.putExtra("date", Calendar.getInstance().get(Calendar.YEAR)+"-"+
											Calendar.getInstance().get(Calendar.MONTH) +"-"+
											Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
		    		startActivityForResult(intent, 1);
				}
				
				Toast.makeText(getApplicationContext(), "Click ListItem Number" + position, Toast.LENGTH_LONG).show();
			}
		});
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_menu_principal, menu);
        return true;
    }
}
